home *** CD-ROM | disk | FTP | other *** search
- Path: hubcap.clemson.edu!hubcap!mjs
- From: mjs@hubcap.clemson.edu (M. J. Saltzman)
- Newsgroups: comp.lang.c
- Subject: Re: division problem
- Date: 2 Feb 96 21:05:00 GMT
- Organization: Clemson University
- Message-ID: <mjs.823295100@hubcap>
- References: <31097D77.11AA@rain.org> <26JAN199622082450@erich.triumf.ca> <4eh246$u6h@airdmhor.gen.nz> <4ej4ha$66@fountain.mindlink.net> <DLzvGG.2rn@uns.bris.ac.uk> <Pine.SOL.3.90.960130150923.21923F-100000@flute> <4etjdj$fil@airdmhor.gen.nz>
- NNTP-Posting-Host: hubcap.clemson.edu
-
- gumboot@airdmhor.gen.nz (Simon Hosie) writes:
-
- > Hello? Can anybody hear me? Ok, let's try again...
-
- >#if -3 / 2 == -2
- > celcius = ((fahrenheit - 32) * 10 + 9) / 18;
- >#else
- > celcius = ((fahrenheit - 32) * 10 + ((fahrenheit - 32 >= 0) ? 9 : -9))
- > / 18;
- >#endif
-
- > There.. complete, portable, accurate rounding.
-
- I'm not so sure. Is there a guarantee that the division as done in
- the compiler's preprocessing phase will give the same result as the
- division done at run time? Language lawyers?
-
- If not, then you need to do the test at run time or use div() to get
- perfectly portable results.
- --
- Matthew Saltzman
- Clemson University Math Sciences
- mjs@clemson.edu
-